#ifndef _SYSCALL_H_INCLUDED_
#define _SYSCALL_H_INCLUDED_

#include "defines.h"
#include "softvec.h"

typedef enum {
    KZ_SYSCALL_TYPE_RUN = 0,
    KZ_SYSCALL_TYPE_EXIT,
    KZ_SYSCALL_TYPE_WAIT,
    KZ_SYSCALL_TYPE_SLEEP,
    KZ_SYSCALL_TYPE_WAKEUP,
    KZ_SYSCALL_TYPE_GETID,
    KZ_SYSCALL_TYPE_CHPRI,
    KZ_SYSCALL_TYPE_KMALLOC,
    KZ_SYSCALL_TYPE_KMFREE,
    KZ_SYSCALL_TYPE_SEND,
    KZ_SYSCALL_TYPE_RECV,
    KZ_SYSCALL_TYPE_RECVA,
    KZ_SYSCALL_TYPE_SETINTR,
    KZ_SYSCALL_TYPE_RESETINTR,
    KZ_SYSCALL_TYPE_GETMSGBOX,
    KZ_SYSCALL_TYPE_FREEMSGBOX,
    KZ_SYSCALL_TYPE_GETTHREADS,
    KZ_SYSCALL_TYPE_RESOURCE,
    KZ_SYSCALL_TYPE_SYSTIME,
} kz_syscall_type_t;

typedef struct {
    union {
        struct {
            kz_func_t func;
            char *name;
            int priority;
            unsigned stacksize;
            int argc;
            char **argv;
            kz_thread_id_t ret;
        } run;
        struct {
            int dummy;
        } exit;
        struct {
            uint32 tick;
            int ret;
        } wait;
        struct {
            int ret;
        } sleep;
        struct {
            kz_thread_id_t id;
            int ret;
        } wakeup;
        struct {
            kz_thread_id_t ret;
        } getid;
        struct {
            int priority;
            int ret;
        } chpri;
        struct {
            int size;
            void *ret;
        } kmalloc;
        struct {
            void *p;
            int ret;
        } kmfree;
        struct {
            kz_msgbox_id_t id;
            int size;
            char *p;
            int priority;
            int maxnum;
            int ret;
        } send;
        struct {
            kz_msgbox_id_t id;
            int *sizep;
            char **pp;
            uint32 tick;
            kz_thread_id_t ret;
        } recv; // recvaと共用
        struct {
            softvec_type_t type;
            kz_handler_t handler;
            int ret;
        } setintr;
        struct {
            softvec_type_t type;
            int ret;
        } resetintr;
        struct {
            kz_msgbox_id_t ret;
        } getmsgbox;
        struct {
            kz_msgbox_id_t id;
            int ret;
        } freemsgbox;
        struct {
            char *ret;
        } getthreads;
        struct {
            char *ret;
        } resource;
        struct {
            uint32 ret;
        } systime;
    } un;
} kz_syscall_param_t;

#endif
